import request from '@/utils/request';

const RECORD_BASE_URL = '/nljs/report/record';

const RecordAPI = {
  // 管理员查询记录
  getRecordPage(params: any) {
    return request({
      url: `${RECORD_BASE_URL}/page`,
      method: 'get',
      params,
    });
  },
  // 用户查询填报记录
  getRecordUser(params: any) {
    return request({
      url: `${RECORD_BASE_URL}`,
      method: 'get',
      params,
    });
  },
  // 记录撤回(用户)
  withdrawRecord(id: string | number) {
    return request({
      url: `${RECORD_BASE_URL}/${id}/withdraw`,
      method: 'post',
    });
  },
  // 批量撤回(用户)
  batchWithdrawRecord(data: string[]) {
    return request({
      url: `${RECORD_BASE_URL}/batch-withdraw`,
      method: 'post',
      data,
    });
  },
  // 提交记录
  submitRecord(id: string | number) {
    return request({
      url: `${RECORD_BASE_URL}/${id}/submit`,
      method: 'post',
    });
  },
  // 批量提交
  batchSubmitRecord(data: any) {
    return request({
      url: `${RECORD_BASE_URL}/batch-submit`,
      method: 'post',
      data,
    });
  },
  // 管理员审批
  approveRecord(id: string | number) {
    return request({
      url: `${RECORD_BASE_URL}/${id}/approve`,
      method: 'post',
    });
  },
  // 批量审批
  batchApproveRecord(data: any) {
    return request({
      url: `${RECORD_BASE_URL}/batch-approve`,
      method: 'post',
      data,
    });
  },
  // 管理员不通过
  rejectRecord(id: string | number, params: any) {
    return request({
      url: `${RECORD_BASE_URL}/${id}/reject`,
      method: 'post',
      params,
    });
  },
  // 批量不通过
  // {
  //   "recordIds": [],
  //   "reason": "", // 不通过理由（仅用于batch-reject）
  //   "note": "" // 操作备注（可选）
  // }
  batchRejectRecord(data: any) {
    return request({
      url: `${RECORD_BASE_URL}/batch-reject`,
      method: 'post',
      data,
    });
  },
  // 获取批次下的填报记录
  getRecordByBatchId(batchId: string | number) {
    return request({
      url: `${RECORD_BASE_URL}/batch/${batchId}`,
      method: 'get',
    });
  },
  getRecordInfo(id: string | number) {
    return request({
      url: `${RECORD_BASE_URL}/${id}`,
      method: 'get',
    });
  },
  updateRecord(data: any) {
    return request({
      url: `${RECORD_BASE_URL}/update`,
      method: 'post',
      data,
    });
  },

  // 获取当前用户的填报记录 无分页
  getRecordByUser() {
    return request({
      url: `${RECORD_BASE_URL}/task`,
      method: 'get',
    });
  },
  // 分页获取当前用户的填报记录
  getRecordPageByUser(params: any) {
    return request({
      url: `${RECORD_BASE_URL}/task/page`,
      method: 'get',
      params,
    });
  },
};

export default RecordAPI;
